/* eslint-disable no-plusplus */
/* eslint-disable import/extensions */
import ElEditable from '@components/el-editable';
import { throttle, isObject } from 'lodash';
import {
  submitOrderChange,
  saveOrderChange,
  downloadFailUploadDataHH,
  downloadFailUploadDataTH,
  uploadReturnedExchangeProduct,
  uploadReturnedProduct,
  salesReturnDetails,
  queryOrderInfo,
  getOrderType,
  echoReturnProductList,
  echoExchangeProductList,
  getOrderAddressList
} from '@api/m_mall_web_v1.js';
import * as CONSTS from './index.const';
import { supplierAndContractComponent } from '~/components/after-sale/supplier-and-contract';
import { productsList } from '~/components/after-sale/products-list';
import { exchangeProductsList } from '~/components/after-sale/exchange-products-list';
import reason from '~/components/after-sale/reason/index.vue';
import addressFunc from '~/components/after-sale/address-func/index.vue';
import { IndexService } from './index.service';

const indexService = new IndexService();

export default {
  name: 'addExchangeOrder',
  inject: ['apiMMallWeb', 'reload'],
  provide: {
    downloadFailUploadDataHH,
    downloadFailUploadData: downloadFailUploadDataTH,
    uploadExchangeProduct: uploadReturnedExchangeProduct,
    uploadProduct: uploadReturnedProduct,
    exTemplateDownLoad:
      'https://md.heng-tai.com.cn/guoke-channel-aggregation-center/api/v1/files/download/9ds2jnta6w6693lv5j57n5328twi2srl.xlsx',
    templateDownLoad:
      'https://mt.heng-tai.com.cn/guoke-channel-aggregation-center/api/v1/files/download/ymj205ernz710fqw3wkbq9sfcqwzlf2n.xlsx'
  },
  data() {
    return {
      ...CONSTS,
      active_index: 1,
      jsTypes: '',
      busModel: '',
      address_all: [], // 编辑时要用
      // 用于接口使用的绑定数据
      submit_data: {
        // 第一步
        supplier_id: '',
        contract_id: '',
        // 第二步类型
        return_type_name: '',
        // return_type_all: '',
        return_type: [
          {
            value: '1',
            label: '寄售退回'
          },
          {
            value: '2',
            label: '寄售消耗退回'
          }
        ],
        busModel: '',
        // 第二步产品
        return_goods: [],
        // 第二步原因
        return_reason: {
          reason_sel: '',
          reason_text: '',
          reason_imgs: [],
          reason_name: ''
        },
        // 第三步选择换货产品
        exchange_goods: [],
        // 第四步承运方式
        carryway_id: '',
        // 第四步地址
        full_address: {},
        orderCode: '',
        orderDetailId: '',
        orderId: '',
        order_type_key: '',
        supplier_data: {},
        contract_data: {}
      },
      address_id: '',
      // 用于页面渲染使用的数据
      render_data: {
        order_type_rows: [],
        rows_carryway: []
      },
      // 用于各种状态的数据
      status: {
        isEdit: false,
        isFirstMount: true,
        dialogVisible: false,
        submit_loading: false
      }
    };
  },
  components: {
    ElEditable,
    supplierAndContractComponent,
    productsList,
    exchangeProductsList,
    reason,
    addressFunc
  },
  async created() {
    this.getFullAddress();
    const resultCarryway = await this.apiMMallWeb.CommonEnumOrderV1ApiPOST({
      query: {
        indexCode: 'transportType'
      }
    });
    this.render_data.rows_carryway = resultCarryway;
  },
  mounted() {
    // 初始化导航栏按钮
    this.initGlobalBtn();
  },
  beforeRouteUpdate(to, from, next) {
    next();
    this.reload();
  },
  computed: {
    routerParams() {
      return {
        orderId: this.$route.query.orderId
      };
    }
  },
  methods: {
    getFullAddress() {
      this.$axios.$post(getOrderAddressList).then(res => {
        this.address_all = res.payload || [];
        if (this.routerParams.orderId) {
          this.getOrderDetailInfo();
        }
      });
    },
    sureToEdit() {},
    // 先说一下这两个接口的详情反显逻辑：（queryOrderInfo和salesReturnDetails，下面用query和sales作为简称）
    // 对于换货单来说，页面routerquery传递的是换货单Id，那么从换货单Id开始作为入口，走queryOrderInfo接口。
    // 该接口获取页面中第四步的所有反显数据。并且从中提取退货单Id。
    // 此时拿到退货单Id后，可以通过getEchoReturnProductList方法获取退货产品数据，
    // 同时因为已经从路由拿到了换货单的id，所以也可以通过getEchoExchangeProductList获取换货产品数据
    // 注意，换货产品数据的获取要依赖退货产品的名称。
    // 此时，还剩“原因”部分数据、第一步数据的反显，从sales接口拿到即可
    getOrderDetailInfo() {
      this.$axios({
        method: 'post',
        url: queryOrderInfo,
        data: {
          orderId: this.routerParams.orderId
        }
      }).then(res => {
        const result = res.data.payload;
        this.reRenderPage(result);
        this.getDetailData(result);
      });
    },
    getDetailData(result) {
      // 编辑模式
      this.$axios({
        url: salesReturnDetails,
        method: 'post',
        data: {
          orderId: result.orderIdReturn
        }
      }).then(res => {
        // eslint-disable-next-line no-shadow
        const newResult = res.data.payload ? res.data.payload : {};
        this.getOrderTypeRowsByEdit(newResult);
        // 设置退货原因
        console.log(result, '180------');
        this.submit_data.return_type_name =
          result.jsType === null ? '' : result.jsType.toString();
        this.submit_data.return_reason.reason_sel =
          newResult.orderData.returnReasonCode;
        this.submit_data.return_reason.reason_text =
          newResult.orderData.returnReasonDetail;
        this.submit_data.return_reason.reason_name =
          newResult.orderData.returnReasonName;
        this.submit_data.return_reason.reason_imgs = newResult.commonFile.map(
          item => item.fileUrl
        );
        // 设置经销商id
        this.submit_data.supplier_id = newResult.orderData.supplierCode;
        // 设置合同id
        this.submit_data.contract_id = this.getContractUnitId(
          newResult.orderData
        );
        this.status.isEdit = true;
        this.getEchoReturnProductList(result);
      });
    },
    getEchoReturnProductList(result) {
      this.$axios({
        method: 'post',
        url: echoReturnProductList,
        data: {
          orderCode: result.orderCodeReturn
        }
      }).then(res => {
        const data = res.data.payload?.content;
        if (
          this.submit_data.return_type_name === '2' ||
          this.submit_data.return_type_name === ''
        ) {
          this.submit_data.return_goods = data.map(it => ({
            ...it,
            attribute1: it.model || it.specs,
            productUnitName: it.productUnit,
            productCount: Number(it.returnQuantity) || 1,
            staticProductCount: Number(it.returnQuantity) || 1, // 这个字段，是用于products-list组件中，更换数量时拦截回归数据使用
            returnCount: Number(it.returnableQuantity),
            referencePrice: it.productPrice,
            mixsIds:
              it.orginalOrderCode +
              it.seqNo +
              it.productCode +
              it.batchNo +
              it.validDate +
              it.referrencePrice
          }));
        } else {
          this.submit_data.return_goods = data.map(it => ({
            ...it,
            productCode: it.productCode,
            productName: it.productName,
            productLineName: it.productLineName,
            productUnitName: it.productUnit,
            attribute1: it.specs,
            batchNo: it.batchNo,
            referencePrice: it.referrencePrice,
            validDate: it.validDate,
            productCount: Number(it.returnQuantity) || 1,
            returnCount: Number(it.returnableQuantity),
            mixsIds:
              it.productCode + it.batchNo + it.validDate + it.referrencePrice
          }));
        }
        this.isReturnProductsOccupy(this.submit_data.return_goods);
        this.getEchoExchangeProductList(result, this.submit_data.return_goods);
      });
    },
    // 判断退货产品是否被其他订单占用
    isReturnProductsOccupy(products) {
      const flag = products.some(
        item => Number(item.returnableQuantity) < Number(item.returnQuantity)
      );
      if (flag) {
        this.$alert('暂存的退换货产品被别的订单使用，请重新添加换货产品', '', {
          confirmButtonText: '知道了',
          callback: () => {
            this.submit_data.return_goods = this.submit_data.return_goods.filter(
              item => Number(item.returnableQuantity) > 0
            );
            this.submit_data.exchange_goods = [];
          }
        });
      }
    },
    getEchoExchangeProductList(result, returnGoods) {
      this.$axios({
        method: 'post',
        url: echoExchangeProductList,
        data: {
          orderCode: result.orderCode,
          returnProductList: returnGoods.map(it => ({
            productName: it.productName,
            returnQuantity: it.returnQuantity
          }))
        }
      }).then(res => {
        const data = res.data.payload?.content;
        this.submit_data.exchange_goods = data.map(it => ({
          ...it,
          attribute1: it.model || it.specs,
          productUnitName: it.productUnit,
          productCount: Number(it.exchangeQuantity),
          exhcangeCount: Number(it.exchangeableQuantity),
          referencePrice: it.productPrice,
          mixsIds: it.productCode
        }));
        this.setInitialProductsDataNums();
      });
    },
    setInitialProductsDataNums() {
      const exProductNamesNum = this.$refs.exchangeProductsList.concatCommonNameProduct(
        this.submit_data.exchange_goods,
        'productCount'
      );
      const returnGoodsCurNums = this.$refs.exchangeProductsList.concatCommonNameProduct(
        this.submit_data.return_goods,
        'productCount'
      );

      // 初始化可选数量
      returnGoodsCurNums.forEach(rGood => {
        this.submit_data.exchange_goods.forEach(item => {
          if (item.productName === rGood.name) {
            this.$set(item, 'optionalQuantity', rGood.commonNameTotalNum);
          }
        });
      });
      // 初始化已选数量
      this.submit_data.exchange_goods.forEach(item => {
        this.$set(item, 'selectedQuantity', 0);
        exProductNamesNum.forEach(exGood => {
          if (item.productName === exGood.name) {
            this.$set(item, 'selectedQuantity', exGood.commonNameTotalNum);
          }
        });
      });
    },
    getContractUnitId(item) {
      return `${item.productLineCode || ''}${item.originalFactoryCode ||
        ''}${item.channelType || ''}${item.busModel ||
        ''}${item.contractInvalidDate || ''}`;
    },
    reRenderPage(result) {
      // 设置地址
      this.jsTypes = result.jsType;
      this.address_id = result.addressResDto.userAddressId;
      let judgeAddress = null;
      if (this.address_all.length > 0) {
        judgeAddress = this.address_all.find(
          item => item.id === result.addressResDto.id
        );
      } else {
        judgeAddress = undefined;
      }
      this.submit_data.full_address =
        judgeAddress !== undefined ? result.addressResDto : {};
      // this.submit_data.full_address = result.addressResDto;
      // 承运方式

      this.submit_data.carryway_id = String(result.transportType || '');
      // 其他id，用于接口提交、暂存使用
      this.submit_data.orderCode = result.orderCode;
      this.submit_data.orderId = result.orderId;
      this.submit_data.orderDetailId = result.orderDetailId;
      // this.submit_data.orderCodeRelate = result.orderCodeRelate;
    },
    getOrderTypeRowsByEdit(result) {
      this.$axios({
        method: 'post',
        url: getOrderType,
        data: {
          busModel: result.orderData.busModel,
          supplierCode: '000'
        }
      }).then(res => {
        // eslint-disable-next-line no-shadow
        const result = res.data.payload || {};
        this.render_data.order_type_rows = result;
        this.submit_data.order_type_key = this.render_data.order_type_rows.find(
          item => item.orderTypeName.includes('换货')
        ).ddbm;
      });
    },
    getBackExchangeGoods(goods) {
      if (!this.status.isEdit) {
        this.submit_data.exchange_goods = goods;
      }
    },
    // 组件回调
    onSupplierAndContractChange(val) {
      console.log(this.jsTypes, '374-------');
      this.submit_data.supplier_data.supplierCode = val.supplierCode;
      this.submit_data.supplier_data.supplierName = val.supplierName;
      this.submit_data.contract_data = val.contract || val;
      this.busModel = this.submit_data.contract_data.busModel;
      this.submit_data.busModel = this.submit_data.contract_data.busModel;
      if (!this.routerParams.orderId) {
        this.submit_data.return_type_name =
          this.submit_data.busModel === '2' ? '1' : '';
      }
      if (this.routerParams.orderId) {
        if (this.jsTypes !== null) {
          this.submit_data.return_type_name = this.jsTypes === 2 ? '2' : '1';
        } else {
          this.submit_data.return_type_name =
            this.submit_data.busModel === '2' ? '1' : '';
        }
      }
      // 清空product
      if (!this.status.isFirstMount) {
        this.submit_data.return_goods = [];
        this.submit_data.exchange_goods = [];
      }
    },
    // 切换退货类型清空退货列表
    changeSelectItem() {
      this.submit_data.return_goods = [];
    },
    getOrderTypeRows(res) {
      this.render_data.order_type_rows = res;
      this.submit_data.order_type_key = this.render_data.order_type_rows.find(
        item => item.orderTypeName.includes('换货')
      ).ddbm;
    },
    getSeledAddress(val) {
      this.submit_data.full_address = val;
    },
    // 全局性初始化配置
    // 导航栏按钮
    // 上一步
    onPrev() {
      if (this.active_index-- <= 1) this.active_index = 1;
      this.initGlobalBtn();
    },
    // 下一步
    onNext() {
      const verifyResult = indexService.verifyStep(
        this.active_index,
        this.submit_data
      );
      if (verifyResult.pass === true) {
        if (this.active_index++ >= 4) this.active_index = 4;
      } else {
        this.$notify({
          type: 'warning',
          title: '请注意',
          message: verifyResult.message
        });
      }
      this.initGlobalBtn();
    },
    // 暂存
    onSaveDraft() {
      const verifyResult = indexService.verifyStep(
        this.active_index,
        this.submit_data
      );
      if (verifyResult.pass === true) {
        this.saveProgress();
      } else {
        this.$notify({
          type: 'warning',
          title: '请注意',
          message: verifyResult.message
        });
      }
    },
    saveProgress: throttle(
      // eslint-disable-next-line func-names
      function() {
        this.$axios({
          url: saveOrderChange,
          method: 'post',
          data: this.splitSubmitDataBySteps()
        })
          .then(res => {
            const order = isObject(res.data.payload) ? res.data.payload : {};
            this.submit_data.orderId = order.orderId;
            this.submit_data.orderDetailId = order.orderDetailId;
            this.submit_data.orderCode = order.orderCode;
            this.$message({
              type: 'success',
              message: '暂存成功'
            });
          })
          .catch(() => {
            this.$message({
              type: 'warning',
              message: '暂存失败'
            });
          });
      },
      3000,
      {
        leading: true,
        trailing: false
      }
    ),
    reStructSubmitData() {
      return {
        busModel: this.busModel,
        jsType:
          this.submit_data.return_type_name && this.busModel === '2'
            ? Number(this.submit_data.return_type_name)
            : null,
        returnReason: this.submit_data.return_reason.reason_sel,
        returnReasonCode: this.submit_data.return_reason.reason_sel,
        returnReasonDetail: this.submit_data.return_reason.reason_text,
        supplierVo: {
          vendorCode: this.submit_data.supplier_data.supplierCode,
          vendorName: this.submit_data.supplier_data.supplierName
        }, // 供应商
        contractVo: {
          ...this.submit_data.contract_data,
          marketCode: this.submit_data.contract_data.channelType,
          supplierCode: this.submit_data.contract_data.originalFactoryCode,
          supplierName: this.submit_data.contract_data.originalFactoryName
        }, // 合同
        saveProductVO: this.submit_data.return_goods, // 采购产品
        saveProductVOChange: this.submit_data.exchange_goods,
        addressResDto: this.submit_data.full_address, // 地址
        commonFileForms: this.submit_data.return_reason.reason_imgs.map(
          item => {
            const name = item.substring(item.lastIndexOf('/') + 1);
            return {
              fileName: name.split('.')[0],
              fileType: name.split('.')[1],
              fileUrl: item
            };
          }
        ), // 原因图片
        transportType: this.submit_data.carryway_id,
        orderCode: this.submit_data.orderCode, // 订单编码
        orderDetailId: this.submit_data.orderDetailId, // 订单详情id
        orderId: this.submit_data.orderId, // 订单id
        orderTypeId: this.render_data.order_type_rows.find(
          item => item.ddbm === this.submit_data.order_type_key
        ).orderTypeId,
        orderType: this.submit_data.order_type_key,
        orderCodeRelate: '',
        createType: 1 // 1独立创建，2原单创建
      };
    },
    onSubmit: throttle(
      // eslint-disable-next-line func-names
      function() {
        // if (this.submit_data.transportType === '1') {
        //   this.submit_data.addressResDto = {};
        // } else {
        //   this.submit_data.addressResDto = this.storageAddress;
        // }
        this.status.submit_loading = true;
        this.$axios({
          url: submitOrderChange,
          method: 'post',
          data: this.reStructSubmitData()
        })
          .then(res => {
            if (res.data.code === '0') {
              this.$router.push('/after-sale/order-management');
              this.$message({
                message: '订单提交成功',
                type: 'success'
              });
            }
          })
          .catch(err => {
            if (err.data.code === '200001') {
              this.$router.push('/after-sale/order-management');
            }
          })
          .finally(() => {
            this.status.dialogVisible = false;
            this.status.submit_loading = false;
          });
      },
      3000,
      {
        leading: true,
        trailing: false
      }
    ),
    isSubmitProductsMatchRules(returnGoods, exchangeGoods) {
      // 需要把双方的同名的整合到一起再做对比
      const rGoods = this.$refs.exchangeProductsList.concatCommonNameProduct(
        returnGoods,
        'productCount'
      );
      const exGoods = this.$refs.exchangeProductsList.concatCommonNameProduct(
        exchangeGoods,
        'productCount'
      );
      const hahaArr = [];
      rGoods.forEach(r => {
        const obj = {
          name: '',
          rNum: 0,
          eNum: 0
        };
        obj.name = r.name;
        obj.rNum = r.commonNameTotalNum;
        exGoods.forEach(curGoods => {
          if (r.name === curGoods.name) {
            obj.eNum = curGoods.commonNameTotalNum;
          }
        });
        hahaArr.push(obj);
      });
      const flag = hahaArr.some(item => item.eNum !== item.rNum);
      return flag;
    },
    // 打开确认提交弹窗
    showConfirmDialog() {
      const verifyResult = indexService.verifyStep(4, this.submit_data);
      if (verifyResult.pass === true) {
        // 做一下退货产品和换货产品匹配的校验
        if (
          this.isSubmitProductsMatchRules(
            this.submit_data.return_goods,
            this.submit_data.exchange_goods
          )
        ) {
          this.$message({
            type: 'error',
            message: '换货数量不正确'
          });
          return;
        }
        this.status.dialogVisible = true;
      } else {
        this.$notify({
          title: '必填项',
          message: verifyResult.message,
          type: 'warning'
        });
      }
    },
    initGlobalBtn() {
      const btnObj = {
        type: 'btn',
        arr: []
      };
      const saveDraftBtn = {
        val: '暂存',
        handle: this.onSaveDraft
      };
      const prevBtn = {
        type: 'primary',
        val: '上一步',
        handle: this.onPrev
      };
      const nextBtn = {
        type: 'primary',
        val: '下一步',
        handle: this.onNext
      };
      const submitBtn = {
        type: 'primary',
        val: '提交',
        handle: this.showConfirmDialog
      };
      if (this.active_index !== 1) {
        btnObj.arr.push(prevBtn);
      }
      if (this.active_index !== 4) {
        btnObj.arr.push(nextBtn);
      } else {
        btnObj.arr.push(submitBtn);
      }
      btnObj.arr.push(saveDraftBtn);
      this.$store.commit('changeLayoutHandle', btnObj);
    },
    getReasonName(reasonName) {
      this.submit_data.return_reason.reason_name = reasonName;
    },
    splitSubmitDataBySteps() {
      const curStep = this.active_index; // 当前步骤
      // 这里跟submit_data一模一样，下面选择性的赋值
      const splitSubmitData = {
        busModel: this.busModel,
        jsType:
          this.submit_data.return_type_name && this.busModel === '2'
            ? Number(this.submit_data.return_type_name)
            : null,
        // financialEntry: '',
        // receiptInvoice: '',
        returnReason: '',
        returnReasonCode: '',
        returnReasonDetail: '',
        transportType: '', // 承运方式
        supplierVo: {}, // 供应商
        contractVo: {}, // 合同
        saveProductVO: [], // 采购产品
        saveProductVOChange: [], // 换货商品
        addressResDto: {}, // 地址
        commonFileForms: [], // 原因图片
        orderCode: this.submit_data.orderCode, // 订单编码
        orderDetailId: this.submit_data.orderDetailId, // 订单详情id
        orderId: this.submit_data.orderId, // 订单id
        orderTypeId: this.render_data.order_type_rows.find(
          item => item.ddbm === this.submit_data.order_type_key
        ).orderTypeId,
        orderType: this.submit_data.order_type_key,
        orderCodeRelate: '',
        createType: 1 // 1独立创建，2原单创建
      };
      // 第一步
      // eslint-disable-next-line default-case
      switch (curStep) {
        // 第一步，只存第一步的合同和供应商
        case 1:
          splitSubmitData.supplierVo = {
            vendorCode: this.submit_data.supplier_data.supplierCode,
            vendorName: this.submit_data.supplier_data.supplierName
          };
          splitSubmitData.contractVo = {
            ...this.submit_data.contract_data,
            marketCode: this.submit_data.contract_data.channelType,
            supplierCode: this.submit_data.contract_data.originalFactoryCode,
            supplierName: this.submit_data.contract_data.originalFactoryName
          };
          break;
        // 除了第一步的，还额外需要产品部分
        case 2:
          splitSubmitData.supplierVo = {
            vendorCode: this.submit_data.supplier_data.supplierCode,
            vendorName: this.submit_data.supplier_data.supplierName
          };
          splitSubmitData.contractVo = {
            ...this.submit_data.contract_data,
            marketCode: this.submit_data.contract_data.channelType,
            supplierCode: this.submit_data.contract_data.originalFactoryCode,
            supplierName: this.submit_data.contract_data.originalFactoryName
          };
          splitSubmitData.saveProductVO = this.submit_data.return_goods;
          splitSubmitData.returnReasonCode = this.submit_data.return_reason.reason_sel;
          splitSubmitData.returnReason = this.submit_data.return_reason.reason_name;
          splitSubmitData.returnReasonDetail = this.submit_data.return_reason.reason_text;
          splitSubmitData.commonFileForms = this.submit_data.return_reason.reason_imgs.map(
            item => {
              const name = item.substring(item.lastIndexOf('/') + 1);
              return {
                fileName: name.split('.')[0],
                fileType: name.split('.')[1],
                fileUrl: item
              };
            }
          );
          break;
        case 3:
          splitSubmitData.supplierVo = {
            vendorCode: this.submit_data.supplier_data.supplierCode,
            vendorName: this.submit_data.supplier_data.supplierName
          };
          splitSubmitData.contractVo = {
            ...this.submit_data.contract_data,
            marketCode: this.submit_data.contract_data.channelType,
            supplierCode: this.submit_data.contract_data.originalFactoryCode,
            supplierName: this.submit_data.contract_data.originalFactoryName
          };
          splitSubmitData.saveProductVO = this.submit_data.return_goods;
          splitSubmitData.returnReasonCode = this.submit_data.return_reason.reason_sel;
          splitSubmitData.returnReason = this.submit_data.return_reason.reason_name;
          splitSubmitData.returnReasonDetail = this.submit_data.return_reason.reason_text;
          splitSubmitData.commonFileForms = this.submit_data.return_reason.reason_imgs.map(
            item => {
              const name = item.substring(item.lastIndexOf('/') + 1);
              return {
                fileName: name.split('.')[0],
                fileType: name.split('.')[1],
                fileUrl: item
              };
            }
          );
          splitSubmitData.saveProductVOChange = this.submit_data.exchange_goods;
          break;
        // 第四步就比较简单了
        case 4:
          splitSubmitData.supplierVo = {
            vendorCode: this.submit_data.supplier_data.supplierCode,
            vendorName: this.submit_data.supplier_data.supplierName
          };
          splitSubmitData.contractVo = {
            ...this.submit_data.contract_data,
            marketCode: this.submit_data.contract_data.channelType,
            supplierCode: this.submit_data.contract_data.originalFactoryCode,
            supplierName: this.submit_data.contract_data.originalFactoryName
          };
          splitSubmitData.saveProductVO = this.submit_data.return_goods;
          splitSubmitData.returnReasonCode = this.submit_data.return_reason.reason_sel;
          splitSubmitData.returnReason = this.submit_data.return_reason.reason_name;
          splitSubmitData.returnReasonDetail = this.submit_data.return_reason.reason_text;
          splitSubmitData.addressResDto = this.submit_data.full_address;

          splitSubmitData.commonFileForms = this.submit_data.return_reason.reason_imgs.map(
            item => {
              const name = item.substring(item.lastIndexOf('/') + 1);
              return {
                fileName: name.split('.')[0],
                fileType: name.split('.')[1],
                fileUrl: item
              };
            }
          );
          splitSubmitData.saveProductVOChange = this.submit_data.exchange_goods;
          splitSubmitData.transportType = this.submit_data.carryway_id;
          break;
      }
      return splitSubmitData;
    },
    clearExchangeGoods() {
      this.submit_data.exchange_goods = [];
    }
  }
};
